package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TGoodsComp;
import com.ruoyi.system.service.ITGoodsCompService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * t_goods_comp 商品企业关系Controller
 * 
 * @author ruoyi
 * @date 2022-04-09
 */
@RestController
@RequestMapping("/system/comp")
public class TGoodsCompController extends BaseController
{
    @Autowired
    private ITGoodsCompService tGoodsCompService;

    /**
     * 查询t_goods_comp 商品企业关系列表
     */
    @PreAuthorize("@ss.hasPermi('system:comp:list')")
    @GetMapping("/list")
    public TableDataInfo list(TGoodsComp tGoodsComp)
    {
        startPage();
        List<TGoodsComp> list = tGoodsCompService.selectTGoodsCompList(tGoodsComp);
        return getDataTable(list);
    }

    /**
     * 导出t_goods_comp 商品企业关系列表
     */
    @PreAuthorize("@ss.hasPermi('system:comp:export')")
    @Log(title = "t_goods_comp 商品企业关系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TGoodsComp tGoodsComp)
    {
        List<TGoodsComp> list = tGoodsCompService.selectTGoodsCompList(tGoodsComp);
        ExcelUtil<TGoodsComp> util = new ExcelUtil<TGoodsComp>(TGoodsComp.class);
        util.exportExcel(response, list, "t_goods_comp 商品企业关系数据");
    }

    /**
     * 获取t_goods_comp 商品企业关系详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:comp:query')")
    @GetMapping(value = "/{pkId}")
    public AjaxResult getInfo(@PathVariable("pkId") Long pkId)
    {
        return AjaxResult.success(tGoodsCompService.selectTGoodsCompByPkId(pkId));
    }

    /**
     * 新增t_goods_comp 商品企业关系
     */
    @PreAuthorize("@ss.hasPermi('system:comp:add')")
    @Log(title = "t_goods_comp 商品企业关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TGoodsComp tGoodsComp)
    {
        return toAjax(tGoodsCompService.insertTGoodsComp(tGoodsComp));
    }

    /**
     * 修改t_goods_comp 商品企业关系
     */
    @PreAuthorize("@ss.hasPermi('system:comp:edit')")
    @Log(title = "t_goods_comp 商品企业关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TGoodsComp tGoodsComp)
    {
        return toAjax(tGoodsCompService.updateTGoodsComp(tGoodsComp));
    }

    /**
     * 删除t_goods_comp 商品企业关系
     */
    @PreAuthorize("@ss.hasPermi('system:comp:remove')")
    @Log(title = "t_goods_comp 商品企业关系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pkIds}")
    public AjaxResult remove(@PathVariable Long[] pkIds)
    {
        return toAjax(tGoodsCompService.deleteTGoodsCompByPkIds(pkIds));
    }
}
